//
//  VisitorTableViewController.swift
//  新浪微博
//
//  Created by 李国伟 on 15/12/6.
//  Copyright © 2015年 李国伟. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {

    //定义一个标记
    private var userLogon = UserAccountViewModel.shareModel.userlogin
    var visitorView:VisitorView?
    
    
  //重写loadView方法
    override func loadView() {
        
        userLogon ? super.loadView() : setUpVisitorView()
    }
    
    
   private  func setUpVisitorView()
    {
        visitorView = VisitorView()
        view = visitorView
        
        //设置登录和注册按钮
        visitorView?.registButton.addTarget(self, action: "clickRegiste", forControlEvents: .TouchUpInside)
        
        visitorView?.longonButton.addTarget(self, action: "clickLogin", forControlEvents: .TouchUpInside)
        //设置顶部导航栏的两个按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "clickRegiste")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "clickLogin")
    }
    
   @objc private func clickRegiste(){
        print("注册")
    }
    
   @objc private func clickLogin(){
    
    //跳转到授权控制中
      let nav = UINavigationController(rootViewController:OauthViewController())
      presentViewController(nav, animated: true, completion: nil)
    }
}
